<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>教师端</title>
    <link rel="stylesheet" href="/css/sel_means.css">
</head>
<body>
<div class="home">
    <header>
        欢迎学号/工号：<%=uid%>，使用学生管理系统，当前您的职务是：<%=posts%>
        <span>【<a href="/logout">退出登录</a>】</span>
    </header>
    <article>
        <ul>
            <li><a href="/add_means">录入学生信息</a></li>
            <li><a href="/sel_means">查看学生资料</a></li>
            <li><a href="/sel_scores">查询学生成绩</a></li>
            <li><a href="/add_scores">添加学生成绩</a></li>
            <li><a href="/home_teach">查看登录日志</a></li>
            <li><a href="/checkpwd">更改密码</a></li>
        </ul>
        <aside>
            <table class="tabs1" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="tds1">学号</td>
                    <td class="tds1">姓名</td>
                    <td class="tds1">性别</td>
                    <td class="tds1">年龄</td>
                    <td class="tds1">出生年月</td>
                    <td class="tds1">操作</td>
                </tr>
                <%result.forEach((item,index)=>{%>
                <tr>
                    <td class="tds2"><%=item.uid%></td>
                    <td class="tds2"><%=item.stu_name%></td>
                    <%if(item.gender==1){%>
                        <td class="tds2">男</td>
                    <%}else{%>
                        <td class="tds2">女</td>
                    <%}%>
                    <td class="tds2"><%=item.age%></td>
                    <td class="tds2"><%=moment(item.birtmp).format('Y年M月')%></td>
                    <td class="tds2"><a href="/means_upd?uid=<%=item.uid%>">修改</a>
                        <a href="javascript:void(0)" onclick="dels(<%=item.uid%>)">删除</a></td>
                </tr>
                <%})%>
            </table>
            <ol>
                <li>
                    <a style="text-decoration: none;padding: 10px;color: white;background-color: darkgrey;" href="/sel_means?page=1">首页</a>
                </li>
                <%for(var i=1;i<=pages;i++){%>
                <li>
                    <a style="text-decoration: none;padding: 10px;color: white;background-color: darkgrey;" class="<%if(page==i){%>default<%}%>" href="/sel_means?page=<%=i%>">
                        <%=i%>
                    </a>
                </li>
                <%}%>
                <li>
                    <a style="text-decoration: none;padding: 10px;color: white;background-color: darkgrey;" href="/sel_means?page=<%=pages%>">尾页</a>
                </li>
            </ol>
        </aside>
    </article>
</div>
</body>
<script type="text/javascript" src="/script/jquery-3.4.1.min.js"></script>
<script>
// 声明一个触发删除的点击事件函数dels，传递参数：当前点击删除的学生学号
    function dels(val) {
        $.post({
            url:'/sel_means/del?uid='+val,
            dataType:'json',
            success:function (test) {
                    if(test.code==1){
                        alert('删除成功');
                        window.location.href='/sel_means';
                    }else{
                        alert('删除失败')
                    }
            }
        })
    }
</script>
</html>